package com.itheima.service.impl;


import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.CleaningUpDataDao;
import com.itheima.pojo.Order;
import com.itheima.service.CleaningUpDataService;
import com.itheima.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service(interfaceClass = CleaningUpDataService.class)
@Transactional
public class CleaningUpDataServiceImpl implements CleaningUpDataService {
    //注入CleaningUpDataDao
    @Autowired
    private CleaningUpDataDao cleaningUpDataDao;
    @Override
    public void clearUpData() throws Exception {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.YEAR,-1);
        Date date = calendar.getTime();
        String orderDate = DateUtils.parseDate2String(date);
        cleaningUpDataDao.cleanByDate(orderDate);
        System.out.println(orderDate);
}
}
